##cmake_minimum_required( VERSION 2.8 )
project("usldb")
find_package( Qt4 REQUIRED )
include( ${QT_USE_FILE} )
INCLUDE_DIRECTORIES(
    ${QT_INCLUDE_DIR}
    ${QT_QTSQL_INCLUDE_DIR}
    ${CMAKE_CURRENT_BINARY_DIR}
    interfases

)

# генерируем деф файл
#check_include_file_cxx("src/def.h" HAVE_DEF)
set(INSTPREF ${CMAKE_INSTALL_PREFIX})
configure_file(src/def.h.in def.h)


set( interfaces_H
        interfaces/iDatabase.h
        interfaces/mdata.h
)

set( core_H
        src/mcore.h
        src/mlog.h
        src/coredialog.h
)

set( core_SRCS
        src/main.cpp
        src/mcore.cpp
        src/mlog.cpp
        src/coredialog.cpp
)
set( UIS
        src/coredialog.ui
)


qt4_wrap_ui(UIS_H ${UIS})

qt4_wrap_cpp( MOC_SOURCES ${core_H} )

#set( RESOURCES res.qrc )
#qt4_add_resources( QRC_SOURCES ${RESOURCES} )

add_executable( usldb ${core_SRCS} ${MOC_SOURCES} ${UIS_H} ) #${QRC_SOURCES})

target_link_libraries( usldb ${QT_LIBRARIES} ${QT_QTSQL_LIBRARIES})

# install for linux
if(${CMAKE_SYSTEM_NAME} STREQUAL Linux)
    set(rootdir ${CMAKE_INSTALL_PREFIX})
    set(rootdir_bin ${rootdir}/bin)
    set(rootdir_lang ${rootdir}/share/usldb/lang)
    set(rootdir_img ${rootdir}/share/usldb/img)
    install(TARGETS usldb DESTINATION ${rootdir_bin})
    install(FILES lang/ru.qm DESTINATION ${rootdir_lang}/core)
    install(FILES files/icon.svg DESTINATION ${rootdir_img}/core)
endif()
# install for mac os x
if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin)
    set(rootdir ${CMAKE_INSTALL_PREFIX})
    set(rootdir_bin ${rootdir}/bin)
    set(rootdir_lang ${rootdir}/share/usldb/lang)
    set(rootdir_img ${rootdir}/share/usldb/img)
    install(TARGETS usldb DESTINATION ${rootdir_bin})
    install(FILES lang/ru.qm DESTINATION ${rootdir_lang}/core)
    install(FILES files/icon.svg DESTINATION ${rootdir_img}/core)
endif()
